<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8" />
    <title>产前诊断信息管理系统</title>
    <meta name="renderer" content="webkit">
    <link rel="shortcut icon" href="/static/cqzd/img/favicon.ico">
    <link rel="Bookmark" href="/static/cqzd/img/favicon.ico"/>
    <script src="../sp/skin2/assets/js/boot.js" type="text/javascript"></script>
    <script>mini.contextPath = mini.contextPath||getPageContext();</script>
    <link href="/static/cqzd/css/indexN.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <!-- <div class="thislog"></div> -->
    <div id="layout1" class="mini-layout homepage" splitSize="0" style="width:100%;height:100%;">
        <!--头部导航栏-->
        <div class="toptooker" headerStyle="height:0px;border:0px;" region="north">
            <div class="thislog"></div>
            <div class="thistitle">
                <!--<div>产前诊断信息管理系统</div>
                <span>PRENATAL DIAGNOSTIC INFORMATION MANAGEMENT SYSTEM</span>-->
            </div>
            <div class="userimg">
                <img src="/static/cqzd/img/userlog.png">
                <dl>
                    <dt id="current-user" onclick="$(this).closest('.userimg').toggleClass('zoom-in');"></dt>
                    <dd><a href="javascript:changePw()" style="color: #fff;">修改密码</a></dd>
                    <dd><a href="javascript:signOut()" style="color: #fff;">退出</a></dd>
                </dl>
            </div>
        </div>
        <!--左侧导航栏-->
        <div class="leftmenu" region="west" headerStyle="height:0px;" width="280px">
            <ul id="menu">
            </ul>
        </div>
        <!--右侧内容-->
        <div class="right-content" region="center">
            <iframe src="static/cqzd/pages/Welcome.html" class="rightcontent"></iframe>
        </div>
    </div>
<!--菜单模板-->
<script id="menu-node-tmpl" type="text/x-jquery-tmpl">
    <li class="nLi">
        <h3 data-url='{%= url%}'><span class="menu-icon">{%html iconCls%}</span><span class="menu-text">{%= text%}</span><i class="menu-arrow zxangle fa fa-angle-down"></i></h3>
        <ul class="sub">
            {%each(i,node) childNodes%}
            <li><a href="javascript:void(false)" data-url='{%= node.url%}'>{%= node.text%}</a></li>
            {%/each%}
        </ul>
    </li>
</script>

<script type="text/javascript">
    !function(){
        //当前登录的用户
        var userName = sessionStorage.getItem('userName');
        if(!userName){
            HttpUtil.get('/security/sign/myInfo',function(msg){
                sessionStorage.setItem('userName',msg.userName);
                sessionStorage.setItem('userOrg',msg.userOrg);
                sessionStorage.setItem('userRole',msg.userRole);
                document.getElementById('current-user').innerHTML = msg.userName;
            });
            return;
        }
        document.getElementById('current-user').innerHTML = userName;
    }();

    function changePw(){
        mini.open({
            url:"/static/cqzd/pages/update_password.html",
            title:'修改密码',
            width:340,
            height:360
        });
    }

    function signOut(){
        mini.confirm("确定退出系统吗？","",function(action) {
            if ("ok" !== action) {
                return;
            }
            location.href = '/security/sign/out';
        });
    }

    $(function() {
        //系统菜单
        var Menu = {
            //菜单数据数组
            menuData:[],
            //菜单数据树
            menuTreeList:[],
            //从后台加载菜单数据
            loadData:function (callback) {
                $.get("/admin/getMenu",function(text){
                    //初始化menuData，过滤隐藏的菜单项
                    Menu.menuData = text.data;
                    for (var i = 0; i < Menu.menuData.length; i++) {
                        if(Menu.menuData[i].isHidden===1){
                            Menu.menuData.splice(i--,1);
                        }
                    }
                    //初始化menuTreeList
                    Menu.menuTreeList = Menu.getChildNode(0);
                    for (var i = 0; i < Menu.menuTreeList.length; i++) {
                        Menu.menuTreeList[i].childNodes = Menu.getChildNode(Menu.menuTreeList[i].id);
                    }
                    //将菜单树渲染到页面中
                    $('#menu-node-tmpl').tmpl(Menu.menuTreeList).appendTo($('#menu'));
                    if(callback)callback();
                });
            },
            //从menuData中获取nodeId的子节点
            getChildNode:function (nodeId) {
                var childNodes=[];
                for(var i = 0; i < Menu.menuData.length; i++){
                    if(nodeId == Menu.menuData[i].pid){
                        childNodes.push(Menu.menuData[i]);
                    }
                }
                if(0==nodeId&&childNodes.length==0){
                    for(var i = 0; i < Menu.menuData.length; i++){
                        childNodes.push(Menu.menuData[i]);
                    }
                    for(var i = 0; i < childNodes.length; i++){
                        for(var j = 0; j < childNodes.length; j++){
                            if(childNodes[j].id==childNodes[i].pid){
                                childNodes.splice(i--,1);
                                j==0;
                            }
                        }
                    }
                    if(childNodes.length===0){
                        return Menu.menuData;
                    }
                }
                return childNodes;
            }

        };
        Menu.loadData(function () {
            //添加菜单的点击效果
            $(".leftmenu .nLi h3").click(function() {
                var _this = this;
                if ($(_this).parent(".nLi").hasClass("on")) {
                    //关闭效果
                    $(_this).next(".sub").slideUp(300, function() {
                        $(_this).parent(".nLi").removeClass("on");
                        $(_this).children('.zxangle').removeClass('fa-angle-up');
                        $(_this).children('.zxangle').addClass('fa-angle-down');
                    });
                } else {
                    //展开效果
                    $(_this).parent(".nLi").siblings('.nLi').children(".sub").slideUp(300, function() {
                        $(_this).parent(".nLi").siblings('.nLi').removeClass("on")
                        $(_this).next(".sub").slideDown(300, function() {
                            $(_this).parent(".nLi").addClass("on");
                            $(_this).parent(".nLi").siblings('.nLi').children('h3').children('.zxangle').removeClass('fa-angle-up');
                            $(_this).parent(".nLi").siblings('.nLi').children('h3').children('.zxangle').addClass('fa-angle-down');
                            $(_this).children('.zxangle').removeClass('fa-angle-down');
                            $(_this).children('.zxangle').addClass('fa-angle-up');

                        });
                    });
                }
            });
            //添加菜单的点击事件
            $("[data-url]").click(function() {
                var src = $(this).data('url');
                if(!src){
                    //src = 'pages/' + $(this).children('a').attr('name') + '.html';
                    return;
                }
                $('.rightcontent').attr('src', src);

                $(".sub li").removeClass('menuclick');
                $(this).addClass('menuclick');
                //更换内容区域iframe的src
            });
        });
    });
</script>

</body>
</html>